package com.zxl.designpattern.behavioral.observer;

/**
 * 当前状况显示
 * 实现了Observer和DisplayElement接口，作为观察者显示当前天气状况
 */
public class CurrentConditionsDisplay implements Observer, DisplayElement {
    private double temperature;  // 温度
    private double humidity;     // 湿度

    @Override
    public void update(double temperature, double humidity, double pressure) {
        this.temperature = temperature;
        this.humidity = humidity;
        display();
    }
    
    @Override
    public void display() {
        System.out.printf("当前状况: 温度 %.1f°C，湿度 %.0f%%%n", temperature, humidity);
    }
}    